﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 只能输入小数点的书
{
    internal class Program
    {
        static void Main(string[] args)
        {
            float[] tt = new float[10] {0,1,2,3,4,5,6,7,8,9 };
            bool hh = false;
            float i = 0; string str = "";
            Console.WriteLine("请输入一个数字：");
            str = Console.ReadLine(); //获取输入的字符串
            try
            {
                i = float.Parse(str);//将输入的字符串转换为整数
            }
            catch
            {             
                Console.WriteLine("输入的不是数字！");
                Main(args);
            }
            for(int f =0;f<10; f++)
            {
                if (tt[f] == i)
                {
                    hh = true;
                }
            }
            if(hh == true)
            {
                Console.WriteLine("输入合法"+ i);
            }
            else
            {
                Console.WriteLine("输入不合法");
                Program.da();
            }
            Console.ReadKey();
        }
        static void da()
        {
            Console.WriteLine("已退出");
            Console.ReadKey();
            Environment.Exit(0);
        }
    }
}
